package system;
import java.sql.*;
public class createQuestion{
	String question_id,test_id,question_type,question_no;
	
	public void setQuestion_id(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            question_id=new String(b);
		} catch(Exception e){}
	}
	public String getQuestion_id(){
		return question_id;
	}
	
	public void setTest_id(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            test_id=new String(b);
		} catch(Exception e){}
	}
	public String getTest_id(){
		return test_id;
	}
	
	public void setQuestion_type(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            question_type=new String(b);
		} catch(Exception e){}
	}
	public String getQuestion_type(){
		return question_type;
	}
	
	public void setQuestion_no(String str){
		try{
			byte b[]=str.getBytes("ISO-8859-1");
            question_no=new String(b);
		} catch(Exception e){}
	}
	public String getQuestion_no(){
		return question_no;
	}
	
	public boolean getCreate(){
		boolean  insert=false;
		String insertCondition="insert into questions values('"+question_id+"','"+test_id+"','"+question_type+"','"+question_no+"')";
		Connection con;
	    Statement sql;
	    try{
	    	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test_system";
		String user = "sa";
		String password = "sa";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement();
		int m=sql.executeUpdate(insertCondition);
		if(m!=0){
			insert=true;			
		}
		con.close();
	}
	catch(SQLException e1){insert=false;}
	return insert;
	}
}